﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;

namespace ThorMVR.Pesquisa
{
    class PesquisasCadastro
    {
        public IList<ClassModels.GeralNaturezaJuridica> pesquisaNaturezaJuridica()
        {
            ISession session = ClassModels.NHibernateHelper.GetCurrentSession();

            IQuery query = session.CreateQuery("FROM GeralNaturezaJuridica");

            IList<ClassModels.GeralNaturezaJuridica> naturezaJuridica = query.List<ClassModels.GeralNaturezaJuridica>();
          
            return naturezaJuridica;
            
        }

        public IList<ClassModels.GeralNaturezaJuridica> pesquisaNaturezaJuridica(String codNatJuridica)
        {
            ISession session = ClassModels.NHibernateHelper.GetCurrentSession();

            IQuery query = session.CreateQuery("FROM GeralNaturezaJuridica WHERE codigo=:codNaturezaJuridica");

            query.SetString("codNaturezaJuridica", codNatJuridica);

            IList<ClassModels.GeralNaturezaJuridica> naturezaJuridica = query.List<ClassModels.GeralNaturezaJuridica>();

            return naturezaJuridica;

        }

        public IList<ClassModels.GeralEmpresas> pesquisaEmpresa()
        {
            ISession session = ClassModels.NHibernateHelper.GetCurrentSession();

            IQuery query = session.CreateQuery("FROM GeralEmpresas");

            IList<ClassModels.GeralEmpresas> empresa = query.List<ClassModels.GeralEmpresas>();

            return empresa;
        }

        public IList<ClassModels.GeralCnae> pesquisaCnae()
        {
            ISession session = ClassModels.NHibernateHelper.GetCurrentSession();

            IQuery query = session.CreateQuery("FROM GeralCnae");

            IList<ClassModels.GeralCnae> cnae = query.List<ClassModels.GeralCnae>();

            return cnae;

        }

        public IList<ClassModels.GeralCnae> pesquisaCnae(String codCnae)
        {
            ISession session = ClassModels.NHibernateHelper.GetCurrentSession();

            IQuery query = session.CreateQuery("FROM GeralCnae WHERE codigo=:codCnae");

            query.SetString("codCnae", codCnae);

            IList<ClassModels.GeralCnae> cnae = query.List<ClassModels.GeralCnae>();

            return cnae;

        }
        
    }


}
